<% include header_index.html %>

<style>

    .header{
        width: 100vw;
        background: white;
    }
    .header_div{
        width: 355px;
        margin: 0 auto;
    }
    .header_div img{
        width: 20px;
        height:20px;
        margin-top: 12px;
    }
    .header_div p{
        font-size: 15px;
        color: #181818;
        line-height: 44px;
        text-align: center;
    }
    .weui-navbar{
        overflow: scroll;
        height:44px;
        padding-left: 10px;
        background: white;
    }
    .weui-navbar__item.weui-bar__item--on{
        background: white;
        color: #ff8000;
    }
    .weui-navbar__item{
        width: 80px;
    }
    .weui-navbar__item:after{
        border: none;
    }
    .weui-navbar:after{
        border:none;
    }
    .weui-navbar__item{
        color: #181818;
        font-size: 13px;
    }
    body{
        background: rgb(243,243,243);
    }
    .weui-navbar__item img{
        height:4px;
        display: none;
    }
    .weui-bar__item--on img{
        display: block;
        margin: 0 auto;
        margin-top: 7px;
    }
    .weui-tab__bd{
        width: 100vw;

    }
    .weui-tab{

    }
    .hide1{
        width: 327px;
        float: left;
        height: 44px;
        overflow: hidden;
    }
    .hide{
        width: 100vw;
        overflow:hidden;
        overflow: scroll;
        height:44px;

    }
    ::-webkit-scrollbar {/*隐藏滚轮*/
        display: none;!important;
    }
    .show{
        width: 1100px;
        height:44px;
    }
    .categroy{
        width:68px;
        margin-left: 20px;
        height: 44px;
        line-height: 44px;
        float: left;
        text-align: center;
        font-size: 13px;
        color: #181818;

    }
    .rq{
        background: white;
        height: 44px;
        width: 100vw;
    }
    .selected{
        font-size: 13px;
        color: #ff8000;
    }
    .categroy img{
        height: 4px;
        position: relative;
        top: -4px;
        margin: 0 auto;
        display: none;
    }
    .selected img{
        display: block;
    }
    .down{
        float: left;
        height:15px;
        margin: 14.5px 16.5px;
    }
    .down_div{
        float: left;
        width:48px;
        height: 44px;
    }
    .search_div{
        width: 100vw;
        height:44px;
        background: white;
    }
    .search_margin_div{
        margin: 0 10px;
        height:44px;
    }
    .input_again{
        width: 40px;
        height:30px;
        /*border-top: 7px solid rgba(0,0,0,0);*/
        margin-top: 7px;
        float: left;
        border-radius: 6px 0 0 6px;
        background: #EEE;
    }
    .search_input{
        width: 260px;
        height:30px;
        float: left;
        border: none;
        background: #EEE;
        border-radius: 0 6px 6px 0;
        margin-top: 7px;
    }
    .input_again img{
        width: 20px;
        height:20px;
        margin: 5px 10px;
    }
    input,textarea{outline:none;}
    .btn{
        width: 55px;
        text-align: center;
        height:44px;
        line-height: 44px;
    }
    .brand_div_list{
        width: 100vw;
        height:auto;
        background: white;
        float: left;
    }
    .brand_div{
        width: 107px;
        height: 107px;
        background: white;
        box-shadow: 1px 1px 10px rgba(0,0,0,0.2);
        margin: 9px;
        border-radius: 6px;
    }
    .brand_title{
        width: 87px;
        margin: 0 auto;
        text-align: center;
        line-height: 36px;
        height:36px;
        font-size: 15px;
        color: #454545;
    }
    .brand_img{

        width: 87px;
        height:40.15px;
        margin: 0 10px;
        margin-top: 6px;
    }
</style>
<div class="big_div">
    <div class="h44 header">
        <div class="header_div h44">
            <img src="images/default_wap/return.png" class="back fl" alt="">
            <img src="images/default_wap/moreblack.png" class="back fr" alt="">
            <p>
                品牌汇
            </p>
        </div>
    </div>

    <div class="rq">
        <!-- 容器 -->
        <div class="weui-tab">
            <div class="hide1">
                <div class="hide">
                    <div class="show" >
                        <div class="categroy" v-for="(cate,index) in cates" v-if="!down" v-bind:class="{selected:select==index+1}"  v-on:click="get_cate(index,cate.uid)">
                            {{cate.category_name}}
                            <img src="images/default_wap/select.png" alt="">
                        </div>
                    </div>
                </div>
            </div>
            <div class="down_div"><img class="down" src="images/default_wap/down.png" alt=""></div>
        </div>

    </div>
    <!--滚动栏-->

    <div class="search_div">
        <div class="search_margin_div">
            <div class="left">
                <div class="input_again">
                    <img src="images/default_wap/search1.png" alt="">
                </div>
                <input type="text" class="search_input" placeholder="請輸入你要查找的品牌">
                <div class="btn fl">搜索</div>
            </div>
        </div>
    </div>
    <!--搜索div-->
    <div class="brand_div_list">

            <div class="brand_div fl" v-for="brand in brand_list">
                <a v-bind:href="'brand_product?cat='+brand.id">
                <p class="brand_title sl1">{{brand.brandname}}</p>
                <img src="images/default_wap/load.png" v-bind:data-src="'http://www.phmall.com.ph/'+brand.logo" class="brand_img" alt="">
                </a>
            </div>

    </div>
    <!--列表-->

    <div class="weui-loadmore">
        <i class="weui-loading"></i>
        <span class="weui-loadmore__tips">正在加载</span>
    </div>
</div>

<script>
    var page = new Vue({
        el: '.big_div',
        data: {
            select:1,
            down:false,
            index:0,
            cates:[],
            brand_list:[],
            start:0,
            cat:'<%= cat %>'
        },
        methods:{
            get_cate:function (index,cate_uid) {
                this.select=index+1;
                this.brand_list=[];
                this.start=0;
                var s=this.brand_list;
                var xx=this;
                $.post('/brand',{cat:cate_uid,start:this.start},function (result) {
                    result=result.data;
                    if(result!=0 && result.length!=0)
                    {
                        result.forEach(function (item,index) {
                            s.push(item);
                            xx.start=xx.start+1;
                        })
                    }
                    else{
                        $.modal({
                            title: "警告",
                            text: "已经没有啦~",
                            buttons: [
                                { text: "確定"}
                            ]
                        });
                    }
                });
            }
        },
        mounted:function(){
            var s=this.brand_list;
            var xx=this;
            $.post("./category",{},function (result) {
                result=result.data;
                page.cates=result;
            });
            $.post('/brand',{cat:'<%= cat %>',start:this.start},function (result) {
                result=result.data;
                if(result!=0 && result.length!=0)
                {
                    result.forEach(function (item,index) {
                        s.push(item);
                        xx.start=xx.start+1;
                    })
                }
                else{
                    $.modal({
                        title: "警告",
                        text: "已经没有啦~",
                        buttons: [
                            { text: "確定"}
                        ]
                    });
                }
            });
        }

    });

    $(document.body).infinite();



    var loading = false;  //状态标记


    $(document.body).infinite().on("infinite", function() {

        if(loading) return;
        loading = true;
        //下拉到底部更新
        $.post('/brand',{cat:page.cat,start:page.start},function (result) {
            result=result.data;
            console.log(result);
            if(result!=0 && result.length!=0)
            {
                result.forEach(function (item,index) {
                    page.brand_list.push(item);
                    page.start++;
                })
            }
            else{
                $.modal({
                    title: "警告",
                    text: "已经没有啦~",
                    buttons: [
                        { text: "確定"}
                    ]
                });
            }
            loading = false;
        });

    });
</script>






<!--底部栏-->
<% include footer.html %>
